package com.example.controller;

import com.example.service.CountDownLatchExampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/count/down/latch/example")
public class CountDownLatchExampleController {

    @Autowired
    private CountDownLatchExampleService countDownLatchExampleService;

    @GetMapping("/latch-task")
    public String latchTask() throws InterruptedException {
        countDownLatchExampleService.executeTasksWithLatch();
        return "所有任务完成";
    }
}
